//要实现当前适配的效果

//1.要实时的获取当前的屏幕宽度

//2.重设html根字体大小


(function () {

    let html = document.documentElement;
    //获取页面中的meta标签
    let meta = document.querySelector("meta[name='viewport']");
    recal()

    function recal() {
        let clientWidth = document.documentElement.clientWidth;
        // console.log(clientWidth);
        //将屏幕等分10份
        let fontSize = clientWidth / 10;

        html.style.fontSize = fontSize + "px";

        html.setAttribute('font-size', fontSize + "px")

        let dpr = window.devicePixelRatio; //屏幕像素比
        html.setAttribute('dpr', dpr)
          // console.log(meta);
        let scale = 1/dpr;//缩放的倍数
        meta.setAttribute("content","width=device-width, initial-scale="+dpr+', maximum-scale=' + scale + ', minimum-scale=' + scale + ', user-scalable=no')

    }

    //onresize 屏幕大小发生改变的时候触发的事件;

    //判断有没有屏幕翻转 orientationchange

    let restEvt = 'orientationchange' in window ? 'orientationcahnge' : 'resize';


  

    window.addEventListener(restEvt, recal)
})()